#ifndef GRADIENT_CGINC
#define GRADIENT_CGINC

sampler2D _GradTex2D;
sampler2D _PermGradTex2D;

float intToFloat(float i)
{
    return (i/255)*2-1;
}

float2 intToFloat(float2 i)
{
    return (i/255)*2-1;
}

float3 intToFloat(float3 i)
{
    return (i/255)*2-1;
}

float4 intToFloat(float4 i)
{
    return (i/255)*2-1;
}

float dot1(float grad, float x)
{
	return dot(intToFloat(grad), x);
}

float dot2(float2 grad, float2 xy)
{
	return dot(intToFloat(grad), xy);
}

float dot3(float3 grad, float3 xyz)
{
	return dot(intToFloat(grad), xyz);
}

float dot4(float4 grad, float4 xyzw)
{
	return dot(intToFloat(grad), xyzw);
}

float4 grad2(float2 perm)
{
	return tex2D(_GradTex2D, perm/_PermTexSize)*255;
}

float4 permGrad2(float perm)
{
	return tex2D(_PermGradTex2D, float2(perm, 0)/_PermTexSize)*255;
}

#endif // GRADIENT_CGINC